package com.example.mvvm.viewmodel.fragment;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.example.mvvm.base.BaseViewModel;
import com.example.mvvm.mode.TaskModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Time: 5/18/2021 11:53
 * Author: TAO
 * Description:
 */
public class ChatsViewModel extends BaseViewModel {

    private MutableLiveData<List<TaskModel>> liveData = new MutableLiveData<>();

    public ChatsViewModel(@NonNull Application application) {
        super(application);
    }

    @Override
    public void onCreate() {
        super.onCreate();
        List<TaskModel> taskModels = new ArrayList<>();
        for (int i = 0; i < 23; i++) {
            if(i==1)break;
            TaskModel taskModel = new TaskModel();
            taskModel.setId("" + System.nanoTime());
            taskModel.setDifficultyLevel("1");
            taskModel.setName("测试" + i);
            taskModels.add(taskModel);
        }
        liveData.postValue(taskModels);
    }

    public MutableLiveData<List<TaskModel>> getLiveData() {
        return liveData;
    }
}
